<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>添加银行</title>
    <script type="text/javascript">
      Ext.onReady(function(){
        
        var name = new Ext.form.TextField({
          fieldLabel: '名称',
          allowBlank: false,
          blankText: "银行名称不能为空",
          name: 'name',
          anchor: '95%'
        });

        var phone = new Ext.form.TextField({
          fieldLabel: '电话',
          name: 'phone',
          anchor: '95%'
        });

        var address = new Ext.form.TextField({
          fieldLabel: '地址',
          name: 'address',
          anchor: '95%'
        });

        var desc = new Ext.form.TextArea({
          fieldLabel: '描述',
          name: 'description',
          height:130,
          anchor: '95%'
        });
        
        var newBankForm = new Ext.FormPanel({
          labelWidth: 55, // label settings here cascade unless overridden
          url:'/bank/create',
          labelAlign: 'right',
          frame:true,
          //title: '添加银行',
          bodyStyle:'padding:5px 5px 0',
          width: 600,
          //height:300,
          items: [name,phone,address,desc],
          buttons: [{
              text: '提交',
              iconCls: 'icon-save',
              handler: function(){
                // check form value
                if (newBankForm.form.isValid()) {
                  this.disable();
                  newBankForm.form.submit({
                    method: 'GET',
                    success: function(result, resp){
                      if (resp.result.info.indexOf("成功") >= 0) {
                        Ext.MessageBox.show({
                          title: '消息',
                          msg: "新增银行资料，操作成功！",
                          buttons: Ext.MessageBox.OK,
                          icon: Ext.MessageBox.INFO
                        });
                      }
                      else {
                        Ext.MessageBox.show({
                          title: '消息',
                          msg: Ext.util.JSON.decode(result.responseText).info,
                          buttons: Ext.MessageBox.OK,
                          icon: Ext.MessageBox.WARNING
                        });                        
                      }
                      newBankWin.destroy();
                    },
                    failure: function(result, response){
                      Ext.MessageBox.show({
                        title: '消息',
                        msg: "通讯失败，请从新操作",
                        buttons: Ext.MessageBox.OK,
                        icon: Ext.MessageBox.WARNING
                      });
                      newBankWin.destroy();
                    }
                  });
                }
                else {
                  Ext.MessageBox.alert('错误提示', '请按要求填写必输选项.');
                }
              }
            },{
              text: '关闭',
              iconCls: 'exit',
              handler: function(){
                newBankWin.destroy();
              }
            }]
        });
        newBankForm.render('new_bank_form');
      })
    </script>
  </head>
  <body>
    <div id="new_bank_form"></div>
  </body>
</html>
